package com.shinowit.web;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value="/stock_info_chart")
public class StockInfoChartController {
	
	@Resource
	private JdbcTemplate jt;


	@RequestMapping(value="/count_by_num")
	public String count_by_num(){
		return "/stock_info/chart_count_by_num";
	}
	
	
	@RequestMapping(value="/chart_data_num")
	@ResponseBody
	public List<Map<String,Object>> getChartData(){
		List<Map<String,Object>> result_data_list= jt.queryForList("select b.merchandise_name,a.num from stock_info a inner join merchandise_info b on a.merchandise_code=b.merchandise_code");
		return result_data_list;
	}

	@RequestMapping(value="/count_by_money")
	public String count_by_money(){
		return "/stock_info/chart_count_by_money";
	}
	
	
	@RequestMapping(value="/chart_data_money")
	@ResponseBody
	public List<Map<String,Object>> getChartDataStockMoney(){
		List<Map<String,Object>> result_data_list= jt.queryForList("select b.merchandise_name as name,(a.num*a.avg_price) as value from stock_info a inner join merchandise_info b on a.merchandise_code=b.merchandise_code");
		return result_data_list;
	}
	
	
}
